package com.example.service.impl;

import com.example.mapper.DataMapper;
import com.example.mapper.EmpMapper;
import com.example.pojo.JobOption;
import com.example.pojo.Result;
import com.example.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private DataMapper dataMapper;

    @Override
    public JobOption getEmpJobData() {
        // 获取员工职位报表统计数据
// 查询员工情感数据统计
List<Map<String, Object>> maps = empMapper.countEmoJobData();

// 提取职位信息列表
List<Object> jobList = maps.stream().map(dataMap ->
        dataMap.get("pos")
).toList();

// 提取人数数据列表
List<Object> dataList = maps.stream().map(dataMap ->
        dataMap.get("num")
).toList();

// 创建并返回JobOption对象，包含职位信息和情感数据
return  new JobOption(jobList,dataList);

    }


    // 获取员工性别报表统计数据
    @Override
    public List<Map<String, Object>> getEmpGenderData() {
        return empMapper.countEmoGenderData();
    }


}

